Skip to content

feat: add NetworkPolicy support for operator and proxy-webhook#3714

Open
jkhelil wants to merge 2 commits into
tektoncd:mainfrom
jkhelil:srvkp-12050-networkpolicy
Open

feat: add NetworkPolicy support for operator and proxy-webhook#3714
jkhelil wants to merge 2 commits into
tektoncd:mainfrom
jkhelil:srvkp-12050-networkpolicy

Conversation

@jkhelil

@jkhelil jkhelil commented Jul 13, 2026

Copy link
Copy Markdown
Member

Summary

Implements NetworkPolicy resources to restrict network access for the operator's own workloads, building on the foundation established by the Tekton Triggers NetworkPolicy implementation.

  • Operator namespace (static): Adds default-deny + pod-scoped NetworkPolicy manifests for the main operator controller pod and the proxy-webhook pod in the operator's own namespace (config/kubernetes/base/networkpolicy.yaml, config/openshift/base/networkpolicy.yaml). These are static because no CR reconciles the operator's own namespace, and the operator is also distributed via OLM bundles.
  • TektonPipeline (reconciled): Adds a spec.networkPolicy field to TektonPipeline (propagated from TektonConfig, mirroring the existing TektonTrigger field) and a new pkg/reconciler/kubernetes/tektonpipeline/networkpolicies.go that reconciles default-deny + proxy-webhook policies in the operand namespace, following the same pattern used by tektontrigger.
  • Both platforms (Kubernetes and OpenShift) are supported via the existing networkpolicy.PlatformParams helper (different DNS/API server ports and label selectors per platform).
  • Updates generated CRDs/Helm chart output and docs/NetworkPolicy.md.

Ref: SRVKP-12050

Test plan

  • go build ./...
  • go vet ./... / gofmt
  • yamllint on new YAML files
  • Unit tests for touched packages pass
  • Manual verification on a live cluster (Kubernetes + OpenShift) that the operator/proxy-webhook pods remain reachable for webhook and metrics traffic with the policies applied

Submitter Checklist

  • Run make test lint before submitting a PR
  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices

Release Notes

Tekton Operator now ships default `NetworkPolicy` resources restricting network access for its own controller and proxy-webhook pods to only DNS, Kubernetes API server, Prometheus metrics, and webhook traffic. `TektonPipeline` also gains a `spec.networkPolicy` field (mirroring `TektonTrigger`) so its proxy-webhook's default-deny and allow policies can be reconciled, overridden, or disabled per component.

Made with Cursor

@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please ask for approval from jkhelil after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 13, 2026
@jkhelil

jkhelil commented Jul 13, 2026

Copy link
Copy Markdown
Member Author

/kind feature

@tekton-robot tekton-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 13, 2026
@codecov-commenter

codecov-commenter commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 25.49%. Comparing base (6a356d3) to head (cb11020).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3714      +/-   ##
==========================================
- Coverage   25.51%   25.49%   -0.02%     
==========================================
  Files         448      449       +1     
  Lines       23309    23370      +61     
==========================================
+ Hits         5948     5959      +11     
- Misses      16675    16725      +50     
  Partials      686      686              
Flag Coverage Δ
unit-tests 25.49% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jkhelil jkhelil changed the title feat: add NetworkPolicy support for operator and proxy-webhook wip feat: add NetworkPolicy support for operator and proxy-webhook Jul 13, 2026
@tekton-robot tekton-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 13, 2026
@jkhelil jkhelil changed the title wip feat: add NetworkPolicy support for operator and proxy-webhook feat: add NetworkPolicy support for operator and proxy-webhook Jul 15, 2026
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 15, 2026
@jkhelil jkhelil force-pushed the srvkp-12050-networkpolicy branch from e99d0f1 to 02c76cd Compare July 15, 2026 07:55
jkhelil and others added 2 commits July 15, 2026 10:50
Ship fixed NetworkPolicies for the operator's own namespace
(tekton-operator / openshift-operators) as static manifests
alongside the Deployment/RBAC, scoping the main operator and CR
admission webhook pods for ingress/egress. No CR watches the
operator's own namespace, so these cannot be reconciled and ship
statically instead. Each podSelector targets this operator's own
pod labels only, never an empty/namespace-wide selector, so the
bundle never affects other pods sharing openshift-operators.

Related to SRVKP-12050.

Signed-off-by: Jawed khelil <jkhelil@redhat.com>
Assisted-by: Claude Sonnet 5 (via Cursor)
Co-authored-by: Cursor <cursoragent@cursor.com>
Reuse the NetworkPolicy foundation built for TektonTrigger to scope
ingress/egress for the proxy-webhook workload TektonPipeline
deploys into the operand namespace. Adds spec.networkPolicy to
TektonPipeline, propagated from TektonConfig, and reconciles it via
a new custom InstallerSet, mirroring the TektonTrigger pattern.

Related to SRVKP-12050.

Signed-off-by: Jawed khelil <jkhelil@redhat.com>
Assisted-by: Claude Sonnet 5 (via Cursor)
Co-authored-by: Cursor <cursoragent@cursor.com>
@jkhelil jkhelil force-pushed the srvkp-12050-networkpolicy branch from 02c76cd to cb11020 Compare July 15, 2026 12:19
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants